var _n5;
var cc__extends = __extends;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_EffectLayer = function (t) {
  function _ctor() {
    // 如果 t 是函数，则调用它并将当前上下文传入
    let result = null !== t && t.apply(this, arguments) || this;

    // 清理属性
    result.touchScrewPrefab = null;
    result.hammerPrefab = null;

    // 返回结果
    return result;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    // 获取当前上下文
    const context = this;

    // 监听 screw_remove 事件
    cc.game.on("screw_remove", function (event) {
      const nodeInWorldSpace = event.node.parent.convertToWorldSpaceAR(event.node.position);
      const localPosition = context.node.convertToNodeSpaceAR(nodeInWorldSpace);

      // 实例化触摸螺丝预制体
      const touchScrewInstance = cc.instantiate(context.touchScrewPrefab);

      // 设置位置和父节点
      touchScrewInstance.position = localPosition;
      touchScrewInstance.parent = context.node;

      // 创建延迟和自我移除的动作
      const delayAction = cc.delayTime(0.25);
      const removeSelfAction = cc.removeSelf();
      const sequenceAction = cc.sequence(delayAction, removeSelfAction);

      // 执行动作
      touchScrewInstance.runAction(sequenceAction);
    }, this);

  };
  _ctor.prototype.playHammerEffect = function (t) {
    // 定义常量
    const DELAY_TIME = 0.7;

    // 将节点的局部坐标转换为世界坐标
    const worldPosition = t.parent.convertToWorldSpaceAR(t.position);

    // 将世界坐标转换为当前节点的局部坐标
    const localPosition = this.node.convertToNodeSpaceAR(worldPosition);

    // 实例化锤子预制体
    const hammerInstance = cc.instantiate(this.hammerPrefab);

    // 设置锤子的位置和父节点
    hammerInstance.position = localPosition;
    hammerInstance.parent = this.node;

    // 创建延迟和自我移除的动作
    const delayAction = cc.delayTime(DELAY_TIME);
    const removeSelfAction = cc.removeSelf();

    // 创建动作序列
    const sequenceAction = cc.sequence(delayAction, removeSelfAction);

    // 执行动作
    hammerInstance.runAction(sequenceAction);

  };
  cc__decorate([ccp_property(cc.Prefab)], _ctor.prototype, "touchScrewPrefab", undefined);
  cc__decorate([ccp_property(cc.Prefab)], _ctor.prototype, "hammerPrefab", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(cc.Component);
exports.default = def_EffectLayer;